'use strict'

module.exports = function* appError(next) {
  try {
    yield next
  }
  catch (err) {
    this.status = err.status || 500
    this.body = {
      error: true,
      message: err.message || 'An error occured',
    }
    return
  }
}